package com.me.waterphase;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;

public class WaterCamera {
	
	private OrthographicCamera camera;	
	public final int VIEWPORT_WIDTH = 480;
	public final int VIEWPORT_HEIGHT = 320;
	
	
	public WaterCamera(){
		camera = new OrthographicCamera(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
		camera.position.set(0, 0, 0);
	}
		
	public WaterCamera(int _width, int _height){
		camera = new OrthographicCamera(_width, _height);
	}
	
	public OrthographicCamera getOrthoCamera(){
		return camera;
	}
		
	public void setViewportSize(int _width, int _height){
		camera.viewportWidth = _width;
		camera.viewportHeight = _height;
	}
	
	public void lookAt(Vector2 _position){
		camera.position.x = _position.x;
		camera.position.y = _position.y;
	}
	
	public void render(){
		
		GL10 gl = Gdx.graphics.getGL10();
		
		//Set the viewport to the camera.
        gl.glViewport(0, 0,
                        (int) camera.viewportWidth, (int) camera.viewportHeight);
        
        camera.apply(gl);
        camera.update();
        
        WaterWorld.getStage().setProjectionMatrix(camera.combined);
	}

	
}
